home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr29 / cadq_010.zip / TESTDQ.CMD < prev    next >
OS/2 REXX Batch file  |  1995-03-16  |  2KB  |  90 lines

  1. /* Sample REXX program demonstrating the data queue library functions */
  2. /* This sample will create a non-keyed data queue, query the data     */
  3. /* queue, send and receive one message, then delete the data queue.   */
  4.  
  5. arg dqname
  6. if dqname = '' then do
  7.   say 'A data queue name must be entered in AS/400 format.'
  8.   say 'Example: TESTDQ QGPL/TESTQ'
  9.   say
  10.   exit
  11. end
  12.  
  13. /* Load the data queues external utility functions */
  14. Call RxFuncAdd 'CADQLoadFuncs', 'CADQUTIL', 'CADQLoadFuncs'
  15. Call CADQLoadFuncs
  16.  
  17. /* Set translation on, peek (non-destructive read) off */
  18. Call CADQSetMode ,1,0
  19. Call ShowResult 'CADQSetMode'
  20.  
  21. /* Create a non-keyed data queue on the default system */
  22. /* Max length=256, FIFO sequence, no force, *ALL authority, include sender */
  23. Call CADQCreate dqname,,256,1,0,0,1,"Test Data Queue"
  24. Call ShowResult 'CADQCreate'
  25.  
  26. /* Query the new data queue */
  27. Call CADQQuery dqname
  28. Call ShowResult 'CADQQuery'
  29.  
  30. say '  Max length:' dq_maxlen
  31. say '  Sequence:  ' dq_seq
  32. say '  Force:     ' dq_force
  33. say '  Sender:    ' dq_sender
  34. say '  Text:      ' dq_text
  35. say '  Key length:' dq_keylen
  36. say
  37.  
  38. /* Clear the data queue */
  39. Call CADQClear dqname
  40. Call ShowResult 'CADQClear'
  41.  
  42. /* Send a message to the data queue */
  43. Call CADQSend dqname,,"Data queue operation successful!"
  44. Call ShowResult 'CADQSend'
  45.  
  46. /* Receive the message from the data queue into REXX variable DQ_DATA */
  47. Call CADQReceive dqname,,2,'DQ_DATA',256
  48. Call ShowResult 'CADQReceive'
  49.  
  50. /* Show the received queue message */
  51. say '  Data:' '"'dq_data'"'
  52. say
  53.  
  54. /* Delete the data queue */
  55. Call CADQDelete dqname
  56. Call ShowResult 'CADQDelete'
  57.  
  58. /* Unload all utility functions */
  59. Call RxFuncDrop 'CADQLoadFuncs'
  60. Call RxFuncDrop 'CADQCreate'
  61. Call RxFuncDrop 'CADQDelete'
  62. Call RxFuncDrop 'CADQClear'
  63. Call RxFuncDrop 'CADQPut'
  64. Call RxFuncDrop 'CADQSend'
  65. Call RxFuncDrop 'CADQReceive'
  66. Call RxFuncDrop 'CADQSetMode'
  67. Call RxFuncDrop 'CADQGetMsg'
  68. Call RxFuncDrop 'CADQQuery'
  69. Call RxFuncDrop 'CADQStop'
  70.  
  71. exit
  72.  
  73. /* Procedure ShowResult: Show the result code from the utility call */
  74. /* If a non-zero result is received, show all error messages */
  75. ShowResult:
  76.   parse arg rtn
  77.  
  78.   say rtn':' result
  79.   if result <> 0 then do
  80.     Call CADQGetMsg
  81.     do while result <> ''
  82.       say result
  83.       Call CADQGetMsg
  84.     end
  85.   end
  86.   say
  87.  
  88. return
  89.  
  90.